home *** CD-ROM | disk | FTP | other *** search
- Path: news.connect.net!usenet
- From: tomw@intelligraphics.com
- Newsgroups: comp.lang.c++
- Subject: Re: Modern "Effecient" Compilers
- Date: 11 Feb 1996 23:19:08 GMT
- Organization: Connection Technologies
- Message-ID: <4flthc$a9m@dallas1.connect.net>
- References: <662_9602110059@csource.blaze.net.au>
- Reply-To: tomw@intelligraphics.com
- NNTP-Posting-Host: igxtest.intelligraphics.com
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <662_9602110059@csource.blaze.net.au>, David.Powell@f309.n632.z3.fidonet.org (David Powell) writes:
- >I would just like to mention something I noticed while compiling a "zero
- >length" (ie consisting only of the line main(){} ) cpp file in BC++ 4.52.
- >I ensured that all RTTI, exceptions etc were off, and used the
- >optmize(size) style for my executable and code nodes of my project. Yet
- >despite this, and only linking the run-time libraries, my small memory
- >model application took up 28kb. Changing to tiny reduced the executable
- >size to 6kb. By not linking in the run-time libraries I managed to produce
- >a 500 byte executable, although it crashed of course. My question is, why
- >does 28k of rubbish get linked into my executable when I am making no
- >external references. (I have all debugging off of course). I thought that
- >only code which resolved external references is linked in. Does anybody no
- >why this problem occurs, or ways of getting around it without rewriting
- >lots of code, I would be most grateful if u would post a reply. It is
- >quite embarrassing when friends using only the "inferior" Turbo Pascal
- >6.0/7.0 compiler can produce 1k files without tweaking anything. Are the
- >compiler writers of today too willing to sacrifice performance for good
- >engineering principals?
-
- The 28K you're seeing is caused partly by the startup code. This should be
- in source/startup/c0x.asm in your Borland tree, assuming they still ship it
- (I haven't looked lately, but they should). The startup code does things
- like copy command-line arguments out of the PSP, set up some interrupt
- handling stuff, and miscellany which I've forgotten. I expect some of it is
- also coming from class/variable instances which may be referenced by the
- startup code or are simply always there. If you want to reduce your code
- to the bare nubbin, take pieces out of c0*.asm. Just be aware of what you
- are doing so that if your program needs command-line parameters for instance
- you can stick that part back in.
-
- Most important, though, don't be embarrassed about it. Turbo Pascal has
- long been very heavily optimized to generate small, fast code and link in
- only what absolutely has to be linked in. It is a one-vendor technology;
- they can do this. C++ is a large, complex language with features that Pascal
- doesn't have. Plus, most linkers have relatively poor resolution. If a C++
- object module with 10 functions is put into a library, and only one of those
- functions is ever called in a program, most linkers include all 10 functions
- in the executable. This hopefully will change in the future, as this can be
- a pretty big hit on executable size. (Although it seems that nobody cares
- much to produce small, tight code anymore.)
-
- In short, this is a bit of a "who cares?" matter. Let your friends brag. 10
- years from now, Turbo Pascal will be a dead and buried product, and
- your friends will have had to move on to another language. C++ will still
- almost certainly be going strong.
-
- +---------------------------------------------------------------------------+
- + Tom Wheeler | Member NRA, NMRA +
- + tomw@intelligraphics.com | OS/2 user, C++ programmer +
- + ------------------------------------------------------------------------- +
- + Postmodernism is the refusal to think. Deconstructionism is the refusal +
- + to believe that anyone else can either. +
- +---------------------------------------------------------------------------+
- + Use or reproduction of this document or the author's email address for +
- + commercial purposes without the author's permission is prohibited. +
- +---------------------------------------------------------------------------+
-
-